class Solution(object):
    def projectionArea(self, grid):
        """
        :type grid: List[List[int]]
        :rtype: int
        """
        n = len(grid)
        total = 0
        for i in range(n):
            total += max(grid[i])
            total += max([grid[j][i] for j in range(n)])
            for j in range(n):
                if grid[i][j] > 0:
                    total += 1
        return total


data = Solution()
grid = [[1, 2], [3, 4]]
print(data.projectionArea(grid))
grid = [[2]]
print(data.projectionArea(grid))
grid = [[1,0],[0,2]]
print(data.projectionArea(grid))